Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve threading behavior #575

Merged
merged 6 commits into from
Aug 21, 2023

Conversation

marner2
Copy link
Collaborator

@marner2 marner2 commented Aug 21, 2023

Adds a caching feature for setters which allows us to notify property changed within the setter rather than waiting for UpdateModel to be called (which is more idiomatic within MVVM).

With this in play, the threaded behavior no longer has to block on potentially expensive ViewModel Updates in order to guarantee well-behaved TwoWay bindings on TextBoxes. Instead, we can schedule ViewModel Updates so that they "drop" intermediate Updates when they start piling up. This is possible because ViewModel Updates are fundamentally transitive with MVU. So for example, vm.Update(model1); vm.Update(model2); vm.Update(model3); always results in the same final view state as vm.Update(model1); vm.Update(model3);

This latter behavior only applies to Elmish in multithreaded mode. It does not change the normal singlethreaded behavior at all.

New model schedules jobs quickly but executes them on low priority so that we can combine updates if the UI starts falling behind.
program.UpdateViewModel(vm, model) is fully transitive so it's safe to skip intermediate updates as long as we get the last one.
@marner2 marner2 merged commit 2c51c56 into elmish:master Aug 21, 2023
1 check passed
@marner2 marner2 deleted the feature/improve_threading_behavior branch August 21, 2023 21:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant